package com.weic.service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.weic.mapper.DeptMapper;
import com.weic.pojo.Dept;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DeptService {

    @Autowired
    DeptMapper deptMapper;

    public Dept getByDeptNO(int deptno){
        return deptMapper.getByDeptNO(deptno);
    }

    public List<Dept> getAll(int pageno ,int pagesize) {
        Page<Dept> deptPage = PageHelper.startPage(pageno, pagesize);
        List<Dept> deptList = deptMapper.getAll();
        System.out.println("当前页:"+deptPage.getPageNum());
        System.out.println("总页数"+deptPage.getPages());
        System.out.println("页大小:"+deptPage.getPageSize());
        System.out.println("总记录数:"+deptPage.getTotal());
        System.out.println("当前页数据"+deptPage.getResult());
        System.out.println("------------------------------");
        // 方式2
        /*PageInfo<Dept> pi =new PageInfo<Dept>(list);
        System.out.println("当前页"+pi.getPageNum());
        System.out.println("总页数"+pi.getPages());
        System.out.println("页大小"+pi.getSize());
        System.out.println("总记录数"+pi.getTotal());
        System.out.println("当前页数据"+pi.getList());*/

        return deptList;
    }
}
